package xcmg.device.service.workBoard;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xcmg.device.dao.mapper.CompanyApplyMapper;
import xcmg.device.dao.mapper.CompanyDealerMapper;
import xcmg.device.dao.mapper.PurchaseRequestMapper;
import xcmg.device.dao.mapper.delivery.DeliveryNoteDetailMapper;
import xcmg.device.dao.mapper.sale.SaleReverseMapper;
import xcmg.device.dao.mapper.salesReturn.ReturnApplyMapper;
import xcmg.device.dao.mapper.split.SplitDetailMapper;
import xcmg.device.dao.mapper.threeGuaranteesPur.ThreeGuaranteesPurMapper;
import xcmg.device.service.report.LackService;
import xcmg.device.service.vo.WorkMainVO;
import xcmg.device.service.vo.split.SplitArrivalVO;

/**
 * Created by sqq on 2018/3/21.
 */
@Service
public class WorkBoardService {
    @Autowired
        private ThreeGuaranteesPurMapper threeGuaranteesPurMapper;

    @Autowired
    private PurchaseRequestMapper purchaseRequestMapper;

    @Autowired
    private SaleReverseMapper saleReverseMapper;

    @Autowired
    private CompanyDealerMapper companyDealerMapper;

    @Autowired
    private DeliveryNoteDetailMapper deliveryNoteDetailMapper;

    @Autowired
    private CompanyApplyMapper companyApplyMapper;

    @Autowired
    private ReturnApplyMapper returnApplyMapper;

    @Autowired
    private LackService lackService;

    @Autowired
    private SplitDetailMapper splitDetailMapper;

    public WorkMainVO workMain(String orgId){
        WorkMainVO workMainVO=new WorkMainVO();
        workMainVO.setThreeGuaranteesCount(threeGuaranteesPurMapper.checkPendingCount(orgId));
        workMainVO.setPurchaseCount(purchaseRequestMapper.checkPendingCount(orgId));
        workMainVO.setSaleReverseCount(saleReverseMapper.checkPendingCount(orgId));
        workMainVO.setSaleReturnCount(returnApplyMapper.checkPendingCount(orgId));
        workMainVO.setDealerCount(companyDealerMapper.checkPendingCount(orgId));
        workMainVO.setMonthlySaleAmont(deliveryNoteDetailMapper.monthlySale(orgId));
        workMainVO.setMonthlyReturnAmont(deliveryNoteDetailMapper.monthlyReturn(orgId));
        workMainVO.setLackInboundCount(lackService.getLackInboundNum(orgId));
        workMainVO.setSplitArrivalCount(splitDetailMapper.arrivalListCount(SplitArrivalVO.generateByOrgId(orgId)));
        return workMainVO;
    }

    public Integer applyCount(){
        return companyApplyMapper.applyCount();
    }

}
